/**
 * Created by Administrator on 2017/5/25.
 */
$(function(){
//注册的正则验证
var number = document.getElementById("number"),
    active = document.getElementById("active"),
    verify = document.getElementById("verify"),
    youname = document.getElementById("youname"),
    code = document.getElementById("code"),
    codeagain = document.getElementById("codeagain");
//手机号
var number1 =/^1[34578]\d{9}$/;
    number.onblur = function(){
        if(number1.test(number.value) == true){
            $(".alert1").css("background","url(../images/img/aaa.jpg) no-repeat").html("");
        }else{
            $(".alert1").css({"display":"block","background":"#fff3d9"}).html("请输入11位电话号码");
            $(".number").css("border","1px solid #ca8365");
        }
    }
//验证码
var active1 =/^\d{4}$/;
    active.onblur = function(){
      if(active1.test(active.value) == true){
        $(".alert2").css("background","url(../images/img/aaa.jpg) no-repeat").html("");
    }else{
        $(".alert2").css({"display":"block","background":"#fff3d9"}).html("请输入4位验证码");
        $(".active").css("border","1px solid #ca8365");
         }
    }
//短信验证码
var verify1 =/^\d{6}$/;
    verify.onblur = function(){
        if(verify1.test(verify.value) == true){
            $(".alert3").css("background","url(../images/img/aaa.jpg) no-repeat").html("");
        }else{
            $(".alert3").css({"display":"block","background":"#fff3d9"}).html("请输入6位短信验证码");
            $(".verify").css("border","1px solid #ca8365");
        }
    }
// 用户名
    var youname1 =/^[\u4E00-\u9FA5A-Za-z0-9_]{4,20}$/;
    youname.onblur = function(){
        if(youname1.test(youname.value) == true){
            $(".alert4").css({"background":"url(../images/img/aaa.jpg) no-repeat","display":"block"}).html("");
        }else{
            $(".alert4").css({"display":"block","background":"#fff3d9"}).html("请输入4-20位用户名");
            $(".youname").css("border","1px solid #ca8365");
        }
    }
//密码
var  strang1= /^(?![A-Z]+$)(?![a-z]+$)(?!\d+$)(?![\W_]+$)\S{6,20}$/;
var  middle1 = /^(a-z|A-Z|0-9){6,20}$/;

    code.onfocus = function(){
        $(".rank").css("display","block");
        code.onkeyup=function(){
            if(code.value.length>0 && code.value.length<6){
                $(".weak").css("background","#f7a06c");
            }else if(code.value.length>5 && code.value.length<7){
                $(".weak").css("background","#f7a06c");
                $(".middle").css("background","#f7a06c");
            }else if(strang1.test(code.value) == true){
                $(".weak").css("background","#f7a06c");
                $(".middle").css("background","#f7a06c");
                $(".strang").css("background","#f7a06c");
            }else{
                $(".weak").css("background","#ddd");
                $(".middle").css("background","#ddd");
                $(".strang").css("background","#ddd");
            }
        }
    }
    code.onblur = function(){
        $(".rank").css("display","none")
        if(code.value.length >7 && code.value.length <21){
            $(".alert5").css({"background":"url(../images/img/aaa.jpg) no-repeat","display":"block"}).html("");
        }else{
            $(".alert5").css({"display":"block","background":"#fff3d9"}).html("请输入8-20位密码");
            $(".code").css("border","1px solid #ca8365");
        }
    }

//确认密码

//    codeagain.onblur = function(){
//        if{codeagain.value == code.value}{
//            $(".alert6").css({"background":"url(../images/img/aaa.jpg) no-repeat","display":"block"}).html("");
//        }else{
//            $(".alert6").css({"display":"block","background":"#fff3d9"}).html("2次密码不一致 ");
//            $(".codeagain").css("border","1px solid #ca8365");
//        }
//    }
    codeagain.onblur = function(){
        if(codeagain.value == code.value && codeagain.value !== ""){
            $(".alert6").css({"display":"block","background":"url(../images/img/aaa.jpg) no-repeat"}).html("");
        }else{
            $(".alert6").css({"display":"block","background":"#fff3d9"}).html("2次密码不一致");
            $("codeagain").css("border","1px solid #ca8356");
        }
    }
//换一换刷新 //
    var a = 0;
    $(".p2 a").click(function(){
        a+=360;
        $(".yanzheng1 img").css({"transform":"rotate("+ a +"deg)","transition":"all 1s"});
    })
//获取验证码倒计时
    $(".get").click(function(){
        clearInterval(timer);
        $(" #second").html("60");
        $(".get").css("display","none");
        $(".get2").css("display","block");
        function run(){
            var s = document.getElementById("second");
            if(s.innerHTML == 0){
                $(".get2").css('display','none');
                $('.get').css('display','block');
                return false;
            }
            s.innerHTML = s.innerHTML * 1 - 1;
        }
        var timer = 0;
        timer = setInterval(run, 1000);
    })



})